#include<iostream>
#include<vector>
using namespace std;
class Solution 
{
public:

    vector<int> occurrencesOfElement(vector<int>& nums, vector<int>& queries, int x) 
    {
        vector<int> temp(nums.size(), 0);
        vector<int> answer(queries.size(), 0);
        int appnum = 0;
        int tempnum = 0;
       
        for(int i=0;i<nums.size();i++)
        {
            if(nums[i] == x)
                temp[i]++;
        } 

        for(int j=0;j<temp.size();j++)
        {
            if(temp[j] == 1)
                appnum++;
        }
        
        for(int k=0;k<queries.size();k++)
        {
            if( queries[k] > appnum)
                answer[k] = -1;
            else
            {
                tempnum = 0;
                for(int l =0;l < temp.size();l++)
                {
                    
                    if(temp[l] == 1)
                    {
                        tempnum++;
                        if(tempnum == queries[k])
                            answer[k] = l;
                            break;
                    }  
                }


            }

        }
        return answer;

    }
};


int main() {
    Solution sol;
    vector<int> nums = {1, 3, 1, 7};
    vector<int> queries = {1, 3, 2, 4};
    int x = 1;
    vector<int> result = sol.occurrencesOfElement(nums, queries, x);
    for (int val : result) {
        cout << val << " ";
    }
    return 0;
}